package August;


import java.util.Scanner;

public class Day0823 {
    //字符串计数
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            String s1 = scanner.next();
            String s2 = scanner.next();
            int len1 = scanner.nextInt();
            int len2 = scanner.nextInt();


            char[] ch1 = s1.toCharArray();
            char[] ch2 = s2.toCharArray();

            int res = 0;

            int[] dp = new int[len2+1];

            for (int i = 1; i <= len2 ; i++) {
                dp[i] = (dp[i-1]*26)%1000007;
                if (i<=s1.length())
                    dp[i] = dp[i]-(ch1[i-1]-96);
                if (i<=s2.length())
                    dp[i] = dp[i]+(ch2[i-1]-96);
                if (i>=len1)
                    res += dp[i];
            }
            System.out.println((res-1)%1000007);
        }
    }


    //最长公共子串
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()){
            String s1 = scanner.next();
            String s2 = scanner.next();
            int Len1 = s1.length();
            int Len2 = s2.length();

            int[][] dp = new int[Len1+1][Len2+1];

            //初始化
            for (int i = 0; i <= Len1 ; i++) {
                for (int j = 0; j <= Len2 ; j++) {
                    dp[i][j] = 0;
                }
            }

            for (int i = 1; i <= Len1 ; i++) {
                for (int j = 1; j <= Len2 ; j++) {
                    if (s1.charAt(i-1) == s2.charAt(j-1))
                        dp[i][j] = dp[i-1][j-1]+1;
                    else
                        dp[i][j] = dp[i-1][j]>dp[i][j-1]? dp[i-1][j]:dp[i][j-1];
                }
            }
            System.out.println(dp[Len1][Len2]);
        }
    }
}
